﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chapter04
{
    public partial class Example104 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void login_Click(object sender, EventArgs e)
        {
            var username = usernameTextBox.Text.Trim();
            var password = passwordTextBox.Text.Trim();
            if (username == "admin" && password == "123456")
            {
                Session["users"] = username;
                Response.Redirect("Example103.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "usernameOrPasswordError", "alert('用户名或密码错误');", true);
            }
        }
    }
}